<template>
  <div class="like">
    <Card><span>猜你喜欢</span></Card>
    <ul>
      <li
        v-for="(item, index) in likeList"
        :key="index"
        @click="goDetail(item.id)"
      >
        <h2>
          <img v-lazy="item.imgUrl" alt="" />
        </h2>
        <div class="wenzi">{{ item.name }}</div>
        <div>
          <span>￥</span>
          <b>{{ item.price }}</b>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import Card from "@/components/home/Card.vue";
export default {
  props: { likeList: Array },
  name: "Like",
  components: { Card },
  methods: {
    goDetail(id) {
      this.$router.push({
        //显式
        path: "/detail",
        query: {
          id: id,
        },
        //隐式
        // name: "Detail",
        // params: { id: id },
      });
    },
  },
};
</script>

<style scoped>
.like {
  padding-bottom: 1.6rem;
}
.like ul {
  display: flex;
  flex-wrap: wrap;
}
.like ul li {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 50%;
}

.wenzi {
  padding: 0 0.16rem;
  width: 93%;
  font-size: 0.373333rem;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.like ul li span {
  font-size: 16px;
  color: #ff0000;
}

.like b {
  font-size: 0.54rem;
  font-weight: 600;
  color: #ff0000;
}
.like img {
  width: 4.6933rem;
  height: 4.6933rem;
}
.like img[lazy="loading"] {
  background-color: #f7f7f7;
}
</style>